import { createStore, applyMiddleware } from 'redux'

const defaultState = {
  token: '我是token',
  borkerId: ''
}

const reducer = (state = defaultState, action: any) => {

  switch(action.type) {
    case 'set_broker_id':
    state.borkerId = action.payload
    return {...state}
  }

  return {...state}
}

const store = createStore(reducer)

// 对 redux中的state仓库做注解 ReturnType 反向注入
export type RootState = ReturnType<typeof store.getState>

export default store;
